package com.bicon.botu.mall.base;

import com.bicon.botu.core.base.annotation.*;
import com.bicon.botu.core.base.config.SystemInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 模块启动类
 *
 * @author 谈东魁
 * @date 2017/7/16 下午 21:56
 */
@SpringBootApplication(exclude= {MongoAutoConfiguration.class,
        MongoDataAutoConfiguration.class,
        JpaRepositoriesAutoConfiguration.class})
@EnableGlobalExceptionHandler
@EnableSystemInterceptor
@EnableHttpLogAspect
@EnableGlobalRedis
@EnableMyBatisPlusConfig
@MapperScan("com.bicon.botu.mall.base.mapper")
public class BaseApplication extends WebMvcConfigurationSupport {

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(BaseApplication.class);
        ApplicationContext applicationContext = springApplication.run(args);
    }

    @Bean
    public SystemInterceptor getMyInterceptor() {
        return new SystemInterceptor();
    }

    /**
     * 配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getMyInterceptor()).addPathPatterns("/**");
    }

}
